<template>
  <div>
       <div class="btn">
      <el-button type="primary" @click="showfrom">添加</el-button>
    </div>
    <list :seckArr="seckArr" @updataSeck="updataSeck" @delSeck="delSeck"></list>
    <forms :obj="obj" @addSeck="addSeck"  @canle="canle" ref="curid" @updataSeck="updataSeck" @updataSeckk="updataSeckk" ></forms>
  </div>
</template>

<script>
import list from './list.vue'
import forms from './form.vue'
import {secklist} from '../../request/api.js'
export default {
    components:{
        list,
        forms
    },
    data() {
      return {
        seckArr:[],
        obj:{
          isshow:false
        }
      }
    },
    methods: {
      delSeck(){
        this.getSeckList()
      },
      updataSeckk(){
        this.obj.isshow = false
        this.getSeckList()
      },
      updataSeck(){
        this.obj.isshow = false
        this.getSeckList()
      },
      updataSeck(id){
        this.obj.isshow =true
        this.$refs.curid.getOneSeck(id)
      },
      canle(){
        this.obj.isshow = false
      },
      addSeck(){
        this.obj.isshow = false
        this.getSeckList()
      },
        showfrom(){
            this.obj.isshow = true
        },
        getSeckList(){
          secklist().then(d=>{
            if(d.data.code ==200){
              this.seckArr = d.data.list
            }
          })
        }
    },
    mounted() {
      this.getSeckList()
    },
}
</script>

<style>
.btn{
   margin: 30px 0;
}
.cell{
  text-align: center;
}
</style>